<?php

/**
 * 短信类库
 * @author	Evan<tangzwgo@163.com>
 * @since	2015-11-26
 */
require_once APP_PATH . DS . 'library' . DS . 'http.lib.php';
require_once APP_PATH . DS . 'library' . DS . 'log.lib.php';
class SMS {
    /**
     * 发送短信
     * @param type $mobile
     * @param type $msg
     * @return boolean
     */
    public static function sendMsg($mobile, $msg) {
        if (!$mobile) {
            return false;
        }
        if (!$msg) {
            return false;
        }

        $un = '';
        $pwd = '';
        $url = "http://222.73.117.158/msg/HttpBatchSendSM";
        
        $params = array();
        $params['account'] = $un;        
        $params['pswd'] = $pwd;
        $params['mobile'] = $mobile;
        $params['msg'] = $msg;
        
        $result = Http::post($url, $params);
        
        //记录短信发送日志
        Log::printLog('sms_sendmsg.log', "[$mobile] [$msg] [$result]", 'sms');
        
        $resultCode = explode(',', $result);
        if ($resultCode[1] == 0) {
            return true;
        } else {
            return false;
        }
    }
}